package de.backtomedieval.research;

import de.backtomedieval.R;

public abstract class AbstractResearch {

	public abstract String getName();
	protected abstract void onLevelUp(Technology technology);
	public abstract String getResearchInfo(int level);
	
	
	private int researchPoints = 0;
	private int fullResearchPoints = 0;
	private int baseResearchPoints = 100;
	private int level = 0;
	
	public int getImage() {
		return R.drawable.research;
	}

	
	
	public int getLevel() {
		return level;
	}



	public boolean isResearched() {
		return level>0;
	}

	public void levelup(Technology technology) {
		level=level+1;
		this.onLevelUp(technology);
	}
	
	public int getResearchPoints() {
		return researchPoints;
	}

	public void setResearchPoints(int researchPoints) {
		this.researchPoints = researchPoints;
	}

	public int getFullResearchPoints() {
		return fullResearchPoints;
	}

	public void setFullResearchPoints(int fullResearchPoints) {
		this.fullResearchPoints = fullResearchPoints;
	}

	public String getResearchPercent() {
		return (this.getFullResearchPoints()-this.getResearchPoints())* 100 /this.getFullResearchPoints() + "%";
	}

	public void setBaseResearchPoints(int baseResearchPoints) {
		this.baseResearchPoints = baseResearchPoints;
	}

	public int getBaseResearchPoints() {
		return baseResearchPoints;
	}
	
	public int calculateNewTechnologyPoints(int base, int tech, int level, int percentPerLevel) {
		int oldTech = (base*(level-1)*percentPerLevel)/100;
		int newTech = (base*(level)*percentPerLevel)/100;
		return tech-oldTech+newTech;
	}

	public int calculateTechnologyPointsOfLevel(int base, int level, int percentPerLevel) {
		return (base*(level)*percentPerLevel)/100;
	}
	
	
}
